home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 5
/
Gekikoh Dennoh Club Vol. 5 (Japan).7z
/
Gekikoh Dennoh Club Vol. 5 (Japan) (Track 01).bin
/
internet
/
webx
/
webxp040.lzh
/
Source
/
Config.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-09-27
|
5KB
|
202 lines
/* Config.c WebXpression.cnf ô╟é▌ì₧é▌ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/xglob.h>
/* WebCache.cnf é┼É▌ÆΦé╖éΘÆlüòé╗é╠Åëè·Æl */
unsigned char hold_online = 1;
unsigned char image_compress = 1;
unsigned char image_quality = 0;
unsigned char key_repeat_1st = 30;
unsigned char key_repeat_2nd = 5;
unsigned char color_mode = 0;
unsigned char refresh_rate = 4;
unsigned short cache_image = 4;
unsigned short webcache_save = 4;
unsigned short history_max = 32;
unsigned short config_color[7];
int line_table_size = 4096;
int link_table_size = 1024;
int link_table_buffer_size = 32768;
int image_table_size = 1024;
int anchor_table_size = 1024;
char text_editor[64];
extern struct _psp *mypsp;
typedef struct {
char *var_name;
unsigned char *var_ptr;
} VAR_CHAR;
VAR_CHAR var_char[]=
{
"hold-online", &hold_online,
"image-compress", &image_compress,
"image-quality", &image_quality,
"key-repeat-1st", &key_repeat_1st,
"key-repeat-2nd", &key_repeat_2nd,
"color-mode", &color_mode,
"refresh-rate", &refresh_rate,
NULL, NULL
};
typedef struct {
char *var_name;
unsigned short *var_ptr;
} VAR_SHORT;
VAR_SHORT var_short[]=
{
"cache-image", &cache_image,
"webcache-save", &webcache_save,
"history-max", &history_max,
NULL, NULL
};
typedef struct {
char *var_name;
unsigned short *var_ptr;
} VAR_RGB;
VAR_RGB var_rgb[]=
{
"color-back", &config_color[0],
"color-str", &config_color[1],
"color-clear", &config_color[2], /* â_â~ü[ */
"color-link", &config_color[3],
"color-fixed-back", &config_color[4],
"color-fixed-highlight", &config_color[5],
"color-fixed-str", &config_color[6],
NULL, NULL
};
typedef struct {
char *var_name;
unsigned int *var_ptr;
} VAR_INT;
VAR_INT var_int[]=
{
"line-table-size", &line_table_size,
"link-table-size", &link_table_size,
"link-table-buffer-size", &link_table_buffer_size,
"image-table-size", &image_table_size,
"anchor-table-size", &anchor_table_size,
NULL, NULL
};
typedef struct {
char *var_name;
unsigned char *var_ptr;
} VAR_STR;
VAR_STR var_str[]=
{
"text-editor", text_editor,
NULL, NULL
};
/* ïNô«Ä₧é╔éPë±é╛é»î─é╬éΩéΘ */
int InitConfig (char *fname)
{
FILE *fp;
short h;
char temp_str[256];
strcpy (temp_str, mypsp->exe_path);
_addlastsep (temp_str);
strcat (temp_str, fname);
/* âJâîâôâgâfâBâîâNâgâèé≡îƒì⌡ */
if ((fp = fopen (fname, "r")) == NULL) {
/* WebXpression.x é╠éáéΘâfâBâîâNâgâèé≡îƒì⌡ */
if ((fp = fopen (temp_str, "r")) == NULL) {
printf ("âRâôâtâBâOâtâ@âCâïé¬ô╟é▀é▄é╣é±\n");
return (-1);
}
}
while (fscanf (fp, "%s", temp_str) != EOF) {
char nl = 0; /* ăìsé╓ìsé¡âtâëâO */
if (ferror (fp) || feof (fp))
break;
h = 0;
do { /* char î^ò╧Éöô╟é▌ì₧é▌ */
if (!strcmp (temp_str, var_char[h].var_name)) {
unsigned int t;
fscanf (fp, "%d", &t);
*var_char[h].var_ptr = (unsigned char) t;
fgets (temp_str, 256, fp); /* ê╚ë║ëⁿìsé▄é┼ô╟é▌Ä╠é─éΘ */
nl = !0;
break;
}
} while (var_char[++h].var_name != NULL);
if (nl)
continue;
h = 0;
do { /* short î^ò╧Éöô╟é▌ì₧é▌ */
if (!strcmp (temp_str, var_short[h].var_name)) {
fscanf (fp, "%hd", var_short[h].var_ptr);
fgets (temp_str, 256, fp); /* ê╚ë║ëⁿìsé▄é┼ô╟é▌Ä╠é─éΘ */
nl = !0;
break;
}
} while (var_short[++h].var_name != NULL);
if (nl)
continue;
h = 0;
do { /* short î^ò╧Éöüir,g,b é┼ÄwÆΦüjô╟é▌ì₧é▌ */
if (!strcmp (temp_str, var_rgb[h].var_name)) {
unsigned int r, g, b;
fscanf (fp, "%d,%d,%d", &r, &g, &b);
*(var_rgb[h].var_ptr) = (unsigned short) ((g << 11) | (r << 6) | (b << 1));
fgets (temp_str, 256, fp); /* ê╚ë║ëⁿìsé▄é┼ô╟é▌Ä╠é─éΘ */
nl = !0;
break;
}
} while (var_rgb[++h].var_name != NULL);
if (nl)
continue;
h = 0;
do { /* int î^ò╧Éöô╟é▌ì₧é▌ */
if (!strcmp (temp_str, var_int[h].var_name)) {
fscanf (fp, "%d", var_int[h].var_ptr);
fgets (temp_str, 256, fp); /* ê╚ë║ëⁿìsé▄é┼ô╟é▌Ä╠é─éΘ */
nl = !0;
break;
}
} while (var_int[++h].var_name != NULL);
if (nl)
continue;
h = 0;
do { /* char[] î^ò╧Éöô╟é▌ì₧é▌ */
if (!strcmp (temp_str, var_str[h].var_name)) {
char *p = var_str[h].var_ptr;
while (fgetc (fp) != (int) '"');
while ((*p++ = (char) fgetc (fp)) != '"');
*(p - 1) = '\0';
fgets (temp_str, 256, fp); /* ê╚ë║ëⁿìsé▄é┼ô╟é▌Ä╠é─éΘ */
nl = !0;
break;
}
} while (var_str[++h].var_name != NULL);
if (nl)
continue;
fgets (temp_str, 256, fp); /* ê╚ë║ëⁿìsé▄é┼ô╟é▌Ä╠é─éΘ */
}
return (0);
}